PDF.co icon

PDF.co

Automate document workflows with OCR, AI invoice parsing, data extraction, conversion, form filling, merging/splitting, and barcode processing. Ideal for invoices, forms, and scanned files.

URL/HTML to PDF

AI-generated

Summary

Converts a web page URL, HTML code, or an HTML template with data into a PDF file using the PDF.co service.

Inputs

  • authentication (required) — Select OAuth2 or API Key authentication for PDF.co.
  • convertType (required) — Choose conversion mode: URL to PDF, HTML to PDF, or HTML Template to PDF.
  • url (required) — The web page URL to convert (when convertType is URL to PDF).
  • html (required) — HTML code to convert (when convertType is HTML to PDF).
  • templateId (required) — ID of the HTML template stored in PDF.co (when convertType is HTML Template to PDF).
  • templateData (required) — JSON or CSV data to inject into the template (when convertType is HTML Template to PDF).
  • advancedOptions.custom — Custom paper size (e.g., '200px 300px').
  • advancedOptions.profiles — JSON string for advanced PDF processing options (e.g., outputDataFormat).
  • advancedOptions.doNotWaitFullLoad — If true, do not wait for full page load before conversion.
  • advancedOptions.name — Custom file name for the output PDF.
  • advancedOptions.footer — HTML footer for the PDF.
  • advancedOptions.header — HTML header for the PDF.
  • advancedOptions.margins — Margins as top right bottom left (e.g., '10px 5mm 10px 5mm').
  • advancedOptions.mediaType — CSS media type to use (print, screen, none).
  • advancedOptions.orientation — Page orientation (portrait, landscape).
  • advancedOptions.expiration — Expiration time in minutes for the output link.
  • advancedOptions.paperSize — Paper size (A0-A6, Legal, Letter, Tabloid); ignore if custom size set.
  • advancedOptions.printBackground — Whether to print background graphics.
  • advancedOptions.callback — Webhook URL to receive the output data.

Output shape

The operation returns the generated PDF as binary data (or as a Base64 string if profiles.outputDataFormat is set) and optionally provides a temporary URL to the PDF.

If a callback URL is supplied, the result is sent there instead of being returned directly.

Examples

Example 1: Convert a public web page to PDF

Set authentication, choose URL to PDF, provide the URL, optionally adjust margins, orientation, etc.

Example 2: Generate an invoice PDF from a template

Set authentication, choose HTML Template to PDF, provide templateId and templateData (JSON/CSV), optionally add header/footer, set paper size, etc.

Links

Discussion